layui.use(["element", 'layer', 'form'], function () {
  var element = layui.element,
    form = layui.form,
    layer = layui.layer;
  // 重新渲染表格
});
// AssetCode  资产代码  

var vm = new Vue({
  el: '#app',
  data: {
    ArrData: [],
    totalVisible: false,
    tableIns: [],
    defaultData: []
  },
  mounted: function () {
    this.init()
  },
  methods: {
    init: function () {
      localStorage.setItem('navigation', '<a href="#">首页</a><span lay-separator="">/</span><a href="">存续期管理</a><span lay-separator="">/</span><a><cite>资产监控</cite></a>');
      var arry = ["1;债券资产A1;200,000;1.00;1.05;+5%;债券;正常;已处置;2", "2;同业存款资产A1;150,000;1.00;0.95;-5%;债券;预警;待处置;2", "3;债券资产B1;100,000;1.00;1.03;+3%;现金存款;正常;-;4", "4;同业存款资产B1;200,000;1.00;0.98;-2%;现金存款;正常;-;4", "5;债券资产A2;200,000;1.00;1.01;+1%;同业存单;正常;-;4", "6;同业存单资产D1;100,000;1.00;0.98;-2%;同业存单;正常;-;4", "7;非标资产A2;100,000;1.00;1.00;0%;非标准化债权类资产;正常;-;1"];
      arry.map(item => {
        var keyData = item.split(";");
        var obj = {};
        keyData.map((item, index) => {
          if (index == 0) {
            obj['id'] = item;
          } else {
            obj['field' + index] = item;
          }
        });
        this.ArrData.push(obj);
      });
      this.defaultData = this.tableIns = this.ArrData;
    },
    search: function () {
      var u1_input = $("#u1_input").val();
      var u2_input = $("#u2_input").val();
      this.ArrData = this.defaultData;
      var Arr = [];
      if (u1_input == 0 && u2_input == 0) {
        this.ArrData = this.defaultData;
        return;
      }
      Arr = this.ArrData.filter(function (item, index) {
        if (u2_input != 0) {
          if (u1_input != 0) {
            var data = item.field5.replace('+', "").replace('-', "").replace('%', "");
            var ar = u1_input.split(",");
            if (u1_input == 6) {
              return data == ar[0];
            } else {
              return ar[0] <= data && data <= ar[1];
            }
          } else {
            return item.field9 == u2_input;
          }
        } else {
          if (u1_input != 0) {
            var data = item.field5.replace('+', "").replace('-', "").replace('%', "");
            var ar = u1_input.split(",");
            if (u1_input == 6) {
              return data == ar[0];
            } else {
              return ar[0] <= data && data <= ar[1];
            }
          }
        }
      });
      this.ArrData = Arr;
    },
    go: function (index) {
      if (index < 2) {
        window.location.href = "../DLZCPZMX/CCXQ_1.html"
      } else if (index == 2 || index == 3) {
        window.location.href = "../DLZCPZMX/CCXQ_2.html"
      } else {
        window.location.href = "../DLZCPZMX/CCXQ_3.html"
      }
    },
    Do: function (num) {
      layui.use('layer', function () {
        var layer = layui.layer;
        layer.confirm('该笔资产是否正常？', {
          icon: 7,
          title: '提示',
          shade: false,
          btnAlign: 'c',
          btn: ['正常', '保持预警']
        }, function (index) {
          vm.ArrData[num].field7 = '正常';
          vm.ArrData[num].field8 = '已处置';
          layer.close(index);
        }, function () {
          return;
        });
      });
    }
  }
})